package com.rc.evcharger.vo.log;

import com.rc.evcharger.common.base.BaseMongoEntity;
import com.rc.evcharger.common.enums.ElecPileStopReasonEnum;
import com.rc.evcharger.common.terminal.FaultCodeResult;
import com.rc.evcharger.model.elec.ElecPile;

import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 电桩故障记录
 */
public class ElecPileFaultRecordLog extends BaseMongoEntity implements Serializable {

    private String epNo; //电桩编号

    private String creatTime;    //创建时间

    private String faultTime;    //故障时间

    private String epFault;   //故障

    public ElecPileFaultRecordLog(FaultCodeResult faultCodeResult, ElecPile elecPile) {

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        this.collectionName = "elec_pile_fault_log" + yyyyMM.format(new Date());


        this.creatTime = sdf.format(new Date());
        this.faultTime = sdf.format(faultCodeResult.getAddTime());
        this.epNo = elecPile.getPileNo();
        super.tenantCode = elecPile.getTenantCode();

        this.epFault = faultCodeResult.getGunNum()+"号枪,";
        for (String s : faultCodeResult.getCode()) {
            //获取电桩故障
            this.epFault += ElecPileStopReasonEnum.getElecPileStopReasonResult(s) + ",";
        }
        this.epFault = this.epFault.substring(0, this.epFault.length() - 1);
    }

    public ElecPileFaultRecordLog() {
        Date now = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        this.creatTime = sdf.format(now);

        this.collectionName = "elec_pile_fault_log" + yyyyMM.format(now);
    }

    public String getCreatTime() {
        return creatTime;
    }

    public void setCreatTime(String creatTime) {
        this.creatTime = creatTime;
    }

    public String getFaultTime() {
        return faultTime;
    }

    public void setFaultTime(String faultTime) {
        this.faultTime = faultTime;
    }

    public String getEpFault() {
        return epFault;
    }

    public void setEpFault(String epFault) {
        this.epFault = epFault;
    }

    public String getEpNo() {
        return epNo;
    }

    public void setEpNo(String epNo) {
        this.epNo = epNo;
    }


}
